package main

func maxAscendingSum(nums []int) int {
	max := 0
	for i := 0; i < len(nums); {
		j := i
		temp := 0
		for ; j < len(nums); j++ {
			if j == i {
				temp += nums[j]
				continue
			}

			if nums[j] < nums[j-1] {
				break
			}
			temp += nums[j]
		}

		if temp > max {
			max = temp
		}

		i = j
	}

	return max
}
